package com.weiyu.bultrasound.core.model.common;

import org.springframework.util.StringUtils;

/**
 *@description 
 *@author abner chow
 *@date 2019-08-13 14:32
 */
public enum FilesCodeEnum {


    MP4("1", "mp4"),
    JPG("2", "jpg"),
    PDF("3", "pdf")
    ;

    protected String code;
    protected String desc;

    private FilesCodeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static String getByCode(String code) {
        String  desc = "";
        if (StringUtils.hasText(code)) {
            for (FilesCodeEnum filesCodeEnum : FilesCodeEnum.values()) {
                if (filesCodeEnum.getCode().equals(code)) {
                    desc = filesCodeEnum.getDesc();
                }
            }
        }
        return desc;
    }

    public static String getCodeByDesc(String desc) {
        String  code = "";
        if (StringUtils.hasText(desc)) {
            for (FilesCodeEnum filesCodeEnum : FilesCodeEnum.values()) {
                if (filesCodeEnum.getDesc().equals(desc)) {
                    code = filesCodeEnum.getCode();
                }
            }
        }
        return code;
    }

}
